package cn.wh.core.io;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

/**
 * @Author wanghao
 * @Date 2022-08-24 22:40
 * @Description: 通过构造方式注入
 */
public class UrlResource implements Resource {

    private final URL url;

    public UrlResource(URL url) {
        this.url = url;
    }

    public URL getUrl() {
        return url;
    }

    @Override
    public InputStream getInputStream() {
        InputStream inputStream=null;
        try {
           inputStream = url.openConnection().getInputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return inputStream;
    }
}
